package cn.tedu.oa.room.controller;

import cn.tedu.oa.base.response.JsonResult;
import cn.tedu.oa.room.pojo.dto.RoomQuery;
import cn.tedu.oa.room.pojo.dto.RoomSaveParam;
import cn.tedu.oa.room.pojo.vo.RoomVO;
import cn.tedu.oa.room.service.RoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/oa1/room")
public class RoomController {
    @Autowired
    private RoomService roomService;

    @GetMapping("/select")
    public JsonResult select(RoomQuery roomQuery) {
        log.debug("查询会议室信息");
        List<RoomVO> list = roomService.select(roomQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    public JsonResult save(RoomSaveParam roomSaveParam) {
        log.debug("新增会议室信息");
        roomService.save(roomSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Integer id) {
        log.debug("删除会议室信息");
        roomService.delete(id);
        return JsonResult.ok();
    }
}
